package com.example.meituanservice.service.impl;

import com.example.meituanservice.Mapper.UserMapper;
import com.example.meituanservice.pojo.User;
import com.example.meituanservice.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserServiceImp implements UserService {

    @Autowired
    UserMapper userMapper;
    @Override
    public User Login(User user) {
        String username = user.getUsername();
        String password = user.getPassword();

        User user1 =  userMapper.selectByUsername(username);
        if(user1==null){
            return null;
        }else if(password.equals(user1.getPassword())){
            return user1;
        }else{
            return null;
        }
    }

    @Override
    public int regist(User user) {
        return userMapper.insert(user);
    }
}
